<?php

    class My_Decorator_Checkbox extends Zend_Form_Decorator_Abstract
    {
        protected $_format = '<div class="row"><input id="%s" name="%s" type="checkbox"/>&nbsp;<label for="%s">%s</label></div>';
     
        public function render($content)
        {
            $element = $this->getElement();
            $name    = htmlentities($element->getName());
            $label   = htmlentities($element->getLabel());
            $id      = htmlentities($element->getId());
            $value   = htmlentities($element->getValue());
     
            $markup  = sprintf($this->_format, $id, $name, $name, $label);
            return $markup;
        }
    }

class My_Decorator_SimpleCombo extends Zend_Form_Decorator_Abstract
{
    protected $_format = '<div class="row"><label for="%s">%s</label></div>';
 
    public function render($content)
    {
        $element = $this->getElement();
        $id      = htmlentities($element->getId());
        $label   = htmlentities($element->getLabel());
 
        $markup = sprintf($this->_format, $id, $label);
 
        return $content;
    }
}

class My_Decorator_SimpleInput extends Zend_Form_Decorator_Abstract
{
    protected $_format = '<div class="row"><label for="%s">%s</label><input id="%s" name="%s" type="text" value="%s"/></div>';
 
    public function render($content)
    {
        $element = $this->getElement();
        $name    = htmlentities($element->getFullyQualifiedName());
        $id      = htmlentities($element->getId());
        $label   = htmlentities($element->getLabel());
        $value   = htmlentities($element->getValue());
 
        $markup  = sprintf($this->_format, $id, $label, $id, $name, $value);
 
        $placement = $this->getPlacement();
        $separator = $this->getSeparator();
        switch ($placement) {
            case self::PREPEND:
                return $markup . $separator . $content;

            case self::APPEND:
            default:
                return $content . $separator . $markup;
        }
    }
}




class Application_Form_GroupFilter extends Zend_Form
{

    public function init()
    { 

    }

    public function Create($url=NULL)
    { 

        $decorator  = new My_Decorator_Checkbox;
      #  $fancylabel = new My_Decorator_SimpleLabel;

        $this->addElement('text', 'find', array(
            'required'   => false,
            'label'      => 'Search for: ', 
            'prefixPath' => array('decorator' => array(
                'My_Decorator' => '/var/www/shadow.net/decorators/',
            )),
            'decorators' => array(
                'SimpleInput' 
            )
        )); 
        $this->addElement('hidden', 'goto', array(
            'required'   => false,
            'value'      => $url
        )); 

        $this->addElement('checkbox', 'full', array(
            'required'   => false,
            'checkedvalue'      => 1,
            'uncheckedvalue'      => 2,
            'label'      => 'Full group search'
        )); 

        $this->addElement('radio', 'filter', array(
            'required'   => false,
            'label'      => 'Display what type of articles:',
            'multiOptions' => array(
                ''         => '(Any)' ,
                'picture'  => 'Pictures',
                'rar'      => 'RAR files',
                'wmv'      => 'Video files',
                'mp3'      => 'Audio Files'
            ),
            'value' => ''  //key of multiOption
        ));   

        // Add the submit button
        $this->addElement('image', 'submit', array(
            'src'      => '/request/icon/button/search.png/caption/Search',
            'ignore'   => true 
        ));
    }
 

}

